import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {UrlService} from '../../common/service/url.service';

@Injectable({
    providedIn: 'root'
})
export class ModelinfoService {
    public hostname = this.url.host;
    // 模型信息的4种REST接口
    public modelinfoUrl = this.hostname + '/bomm/modelinfo';
    // 根据ID查询模型信息
    public modelinfoByIDUrl = this.hostname + '/bomm/modelinfobyid';
    // 根据JSON查询模型信息
    public modelinfoByJSONUrl = this.hostname + '/bomm/modelinfobyjson';

    // FastDFS文件存储地址
    public fastdfsUrl = this.url.fastdfsAddress + '/';

    constructor(
        private url: UrlService,
        private http: HttpClient
    ) {
    }

    // 根据JSON查
    queryDataByJson(data: any): any {
        return new Promise((resolve, reject) => {
            this.http.post(this.modelinfoByJSONUrl, data).toPromise().then(res => {
                resolve(res);
            }, error => {
                reject(false);
            });
        });
    }

}
